import React from 'react';
import { IUserTableService } from '../type';

export interface IUserManageContext {
  curRes: any;
  userFixCls: string;
  leftTreeData: any[];
  userTreeLoading: boolean;
  reloadLeftTree: () => void;
  searchValueTree: string;
  selectTreeKeys: string[];
  expandedTreeKeys: string[];
  userManDispatch: React.Dispatch<any>;
  autoExpandParent: boolean;
  reloadRightTable: (opt: IUserTableService) => void;
  rightTablePagination: Record<string, any>;
  leftTreeType: Record<string, any>;
  searchFormValues: Record<string, any>;
  rightRoladTabieUser: () => void;
}

const INIT_USERMANAGE_VALUE: IUserManageContext = {
  userFixCls: '',
  curRes: {},
  leftTreeData: [],
  userTreeLoading: false,
  reloadLeftTree: () => {},
  searchValueTree: '',
  selectTreeKeys: [],
  expandedTreeKeys: [],
  userManDispatch: () => {},
  autoExpandParent: false,
  reloadRightTable: () => {},
  rightTablePagination: {},
  leftTreeType: {},
  searchFormValues: {},
  rightRoladTabieUser: () => {},
};

export const UserManageContext = React.createContext<IUserManageContext>(INIT_USERMANAGE_VALUE);

export interface IUserOtherHandleContext {
  userOthDispatch: React.Dispatch<any>;
  currentStep: number;
  secopeLeftSearValue: string;
  twoLeftExpandedKeys: string[];
  twoAutoExpandParent: boolean;
  twoLeftSelectKeys: string[];
  twoLeftSelectRows: Record<string, any>[];
  secopeRightSearValue: string;
  userDetailSearchValue: string;
}

const INIT_USEROTHERHANDLE_VALUE: IUserOtherHandleContext = {
  userOthDispatch: () => {},
  currentStep: 0,
  secopeLeftSearValue: '',
  twoLeftExpandedKeys: [],
  twoAutoExpandParent: false,
  twoLeftSelectKeys: [],
  twoLeftSelectRows: [],
  secopeRightSearValue: '',
  userDetailSearchValue: '',
};

export const UserOtherHandleContext = React.createContext<IUserOtherHandleContext>(INIT_USEROTHERHANDLE_VALUE);
